package com.gosophia.taskManagement.action;

import java.util.Collections;
import java.util.List;

import net.sf.json.JSONArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.gosophia.commons.web.action.BaseSupportAction;
import com.gosophia.dataDictionary.dto.DataValueDTO;
import com.gosophia.dataDictionary.ws.DataDictionaryWebService;

/**
 * 跳转到任务查询列表
 * @author mayue
 *
 */
@Controller("ToAllMissionListAction")
@Scope("prototype")
public class ToAllMissionListAction extends BaseSupportAction{

    private static final long serialVersionUID = 1L;
    
    private String importanceString ;

    private String missionTypeString;
    @Autowired
    private DataDictionaryWebService dataDictionaryWebService;

    
    
    private static final Long IMPORTANCE_ENTRYID = 1014L;
    
    private static final Long MISSIONTYPE_ENTRYID =1015L;
    
    @Override
    public String _execute() throws Exception {
        //获取重要程度列表
        List<DataValueDTO> importanceList = dataDictionaryWebService.findEnabledDataValueByEntryId(IMPORTANCE_ENTRYID);
        if(importanceList!=null){
            Collections.reverse(importanceList);
            importanceString = JSONArray.fromObject(importanceList).toString().replace("\"", "\\\"");
        }
        
        //任务类型列表
        List<DataValueDTO> missionTypeList = dataDictionaryWebService.findEnabledDataValueByEntryId(MISSIONTYPE_ENTRYID);
        if(missionTypeList!=null){
            missionTypeString = JSONArray.fromObject(missionTypeList).toString().replace("\"", "\\\"");
        }
        
        return SUCCESS;
    }

    public String getImportanceString() {
        return importanceString;
    }

    public void setImportanceString(String importanceString) {
        this.importanceString = importanceString;
    }

    public String getMissionTypeString() {
        return missionTypeString;
    }

    public void setMissionTypeString(String missionTypeString) {
        this.missionTypeString = missionTypeString;
    }
   
}
